<template>
  <div class="shelf-item-category">
    <div class="shelf-item-category-list" v-if="data.list.length > 0">
      <div class="shelf-item-category-item" v-for="(item, index) in data.list" :key="index">
        <img :src="item.cover" class="shelf-item-category-img">
      </div>
    </div>
    <div class="shelf-item-category-bg" v-else>
      <span class="icon-book2"></span>
    </div>
  </div>
</template>

<script>
  export default {
    props: {
      data: Object
    }
    // mounted() {
    //   // console.log('别的页面拿到的数据', this.data)
    // }
  }
</script>

<style lang="scss" rel="stylesheet/scss" scoped>
  @import "../../assets/styles/global";
   .shelf-item-category {
    width: 100%;
    height: 100%;
    overflow: hidden;
    .shelf-item-category-list {
      //水平布局可以换行
      display: flex;
      flex-flow: row wrap;
      //  靠顶部居左显示
      align-content: flex-start;
      width: 100%;
      height: 100%;
      padding-top: px2rem(10);// 5
      box-sizing: border-box;
      .shelf-item-category-item {
        flex: 0 0 33.33%;
        width: 33.33%;
        height: 33.33%;
        box-sizing: border-box;
        // 选中第1/4/7元素
        &:nth-child(3n+1) {
          padding: 0 px2rem(5) px2rem(10) px2rem(10);// 0 2.5 5 5
        }
        // 选中第2/5/8元素
        &:nth-child(3n+2) {
          padding: 0 px2rem(5) px2rem(10) px2rem(5);//0 2.5 5 2.5
        }
        // 选中第3/6/9元素
        &:nth-child(3n+3) {
          padding: 0 px2rem(10) px2rem(10) px2rem(5);// 0 5 5 2.5
        }
        .shelf-item-category-img {
          width: 100%;
          height: 100%;
        }
      }
    }
    .shelf-item-category-bg {
      width: 100%;
      height: 100%;
      background: white;
      font-size: px2rem(30);
      color: #ccc;
      @include center;
    }
    .shelf-item-category-bg {
      width: 100%;
      height: 100%;
      background: white;
      font-size: px2rem(30);
      color: #ccc;
      @include center
    }
  }
</style>
